import { createStore } from "vuex";

export default createStore({
    state: {
        // 数据
        title: '我母鸡得啦~'
    },
    mutations: {
        // 类似reducers
        setTitle(state, payload) {
            state.title = payload;
        }
    },
    actions: {
        // 类似effects
        set_title_actions(context, title) {
            context.commit('setTitle', title)
        }
    },
    getters: {
        // 计算属性
        charToLarger(state, getters) {
            return getters.toUpper
        },
        toUpper(state) {
            return state.title.toUpperCase()
        }
    }
})